package com.linln.admin.system.controller;

import com.linln.modules.system.domain.Product;
import com.linln.modules.system.service.ProductService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;

/**
 * @author WuKai
 * @date 2021/6/26 11:12
 */
@Controller
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping("/product")
    @RequiresPermissions("customize:product:index")
    @ResponseBody
    public Page index(Model model,Product product){
        product.setPrice(new BigDecimal(1).setScale(2));
        product.setStatus((byte)1);
        product.setStrorName("a");
        Page<Product> product2 = productService.findProduct(product);
        model.addAttribute("list",product2.getContent());
        model.addAttribute("page",product2);
        return product2;
        //return "/system/pro/index";
    }
}


